package com.devunion.bogdan.persistence;

import org.springframework.orm.hibernate3.HibernateTemplate;
import org.apache.log4j.Logger;

import java.io.Serializable;

/**
 * <p>Abstract class for all DAO objects.</p>
 *
 * @author Viktar Liaskovich
 * @param <T> DOCUMENT ME!
 */
public abstract class BaseDaoObject<T> implements Serializable, Dao<T> {
    protected Logger log = Logger.getLogger(getClass());

    protected HibernateTemplate hibernateTemplate;

    public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
        this.hibernateTemplate = hibernateTemplate;
    }

    /**
     * {@inheritDoc}
     */
    public void saveOrUpdate(T obj) {
        hibernateTemplate.saveOrUpdate(obj);
    }

    /**
     * {@inheritDoc}
     */
    public void save(T obj) {
        hibernateTemplate.save(obj);
    }

    /**
     * {@inheritDoc}
     */
    public void update(T obj) {
        hibernateTemplate.update(obj);
    }

    /**
     * {@inheritDoc}
     */
    public void delete(T obj) {
        hibernateTemplate.delete(obj);
    }

    /**
     * {@inheritDoc}
     */
    public void refresh(T obj) {
        hibernateTemplate.refresh(obj);
    }
}
